//
//  LSQInterestTableViewCell.m
//  Style
//
//  Created by dllo on 15/9/24.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LSQInterestTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "HuaBaoModel.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>

@implementation LSQInterestTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self ) {
        
        self.imageViewPic = [[UIImageView alloc]init];
        [self addSubview:self.imageViewPic];
        self.imageViewPic.layer.cornerRadius = 1;
        self.imageViewPic.layer.masksToBounds = YES;
        
        self.labelTitle = [[UILabel alloc]init];
        [self addSubview:self.labelTitle];
        self.labelTitle.textColor = [UIColor blackColor];
        self.labelTitle.font = [UIFont systemFontOfSize:16];
        
        
        self.labelSummary = [[UILabel alloc]init];
        [self addSubview:self.labelSummary];
        self.labelSummary.textColor = [UIColor darkGrayColor];
        self.labelSummary.font = [UIFont systemFontOfSize:13];
       
        
        
        
        self.viewSmall = [[UIView alloc]init];
        [self addSubview:self.viewSmall];
        self.viewSmall.backgroundColor =[UIColor blackColor];
        
        
        self.imageViewAuthor = [[UIImageView alloc]init];
        [self addSubview:self.imageViewAuthor];
        self.imageViewAuthor.image = [UIImage imageNamed:@"autho.png"];
        
        
        self.labelAuthor = [[UILabel alloc]init];
        [self addSubview:self.labelAuthor];
        self.labelAuthor.font = [UIFont systemFontOfSize:12];
        
        self.imageViewZheng = [[UIImageView alloc]init];
        [self addSubview:self.imageViewZheng];
        self.imageViewZheng.image = [UIImage imageNamed:@"zhengfangxing.png"];
        
        self.labelTags = [[UILabel alloc]init];
        [self.imageViewZheng addSubview:self.labelTags];
        self.labelTags.textColor = [UIColor blackColor];
        //self.labelTags.backgroundColor = [UIColor blackColor];
        self.labelTags.layer.cornerRadius = 2;
        self.labelTags.font = [UIFont boldSystemFontOfSize:12];
        self.labelTags.layer.cornerRadius = 3;
        self.labelTags.layer.masksToBounds = YES;
        self.labelTags.textAlignment = 1;
        
        
        
        

        }
   
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.imageViewPic mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self).with.offset(13);
        make.left.equalTo(self.mas_left).with.offset(15);
        make.size.mas_equalTo(CGSizeMake(95, 95));
    }];
   
    [self.labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
       make.left.equalTo(self.imageViewPic.mas_right).with.offset(20);
       make.size.mas_equalTo(CGSizeMake(self.frame.size.width, 30));
       make.top.equalTo(self).with.offset(11);
        
    }];
    
    [self.labelSummary mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.imageViewPic.mas_right).with.offset(20);
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width, 25));
        make.top.equalTo(self.labelTitle).with.offset(33);
        
    }];
    

    
    self.labelTags.frame = CGRectMake(3, 2.5, 28, 13);
    
    [self.imageViewAuthor mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.labelTags.mas_right).with.offset(98);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        make.top.equalTo(self.labelSummary).with.offset(48);
        
    }];
    
    [self.labelAuthor mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.imageViewAuthor.mas_right).with.offset(2);
        make.size.mas_equalTo(CGSizeMake(100, 18));
        make.top.equalTo(self.labelSummary).with.offset(46.5);
        
    }];
    
    [self.imageViewZheng mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.imageViewPic.mas_right).with.offset(20);
        make.size.mas_equalTo(CGSizeMake(35, 20));
        make.top.equalTo(self.labelSummary).with.offset(45);
        
}];
    
}

-(void)setModel:(HuaBaoModel *)model
{
    _model = model;
    
    [self.imageViewPic sd_setImageWithURL:[NSURL URLWithString:self.model.icon_url] placeholderImage:[UIImage imageNamed:@"zhanweitu.png"]];
    
    self.labelTitle.text = self.model.title;
    self.labelSummary.text = self.model.summary;
    self.labelTags.text = self.model.tags;
    self.labelAuthor.text = self.model.author;
}

- (void)awakeFromNib {
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
